package main

import "fmt"

func main() {
	res := twoSum([]int{2, 7, 11, 15}, 9)
	fmt.Print(res)
}

func twoSum(nums []int, target int) []int {
	result := make(map[int]int, len(nums))
	var arr []int
	for k, v := range nums {
		_, ok := result[target-v]
		if ok {
			arr = []int{result[target-v], k}
		}
		result[v] = k
	}
	return arr
}
